<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<div class="header">
	<h3>&nbsp;&nbsp;${model.name }</h3>
</div>

<hr>

<form class="validate" id="roleResouceForm" action="app/role/saveRoleResouce">
	<input type="hidden" id="id" name="id" value="${model.id }" /> <input
		type="hidden" id="rs" name="rs" value="${rs }" /> <input type="hidden"
		id="resourceValue" name="resourceValue" />
</form>
<div id="roleResource">
	<isperp:tree id="resourceTree" modal="false">
		<isperp:async enable="true" url="app/role/getResource${rs }"
			otherParam="[\"roleId\",$('#id').val()]"></isperp:async>
		<isperp:check enable="true"></isperp:check>
		<isperp:view showLine="false" showTitle="false" showIcon="false"></isperp:view>
	</isperp:tree>
</div>

<isperp:buttonList>
	<button class="submit"
		onclick="setCheckedNodes();isperp.submitForm();return false;">
		<span class="icon icon-save"></span>提交
	</button>
</isperp:buttonList>
<script type="text/javascript">
	function setCheckedNodes() {
		var nodes = resourceTree.zTree.getCheckedNodes(true);
		var nStr = "";
		$(nodes).each(function(index, node) {
			nStr += node.id + ",";
		});
		$("#resourceValue").val(nStr);
		return true;
	}

	function roleUser_beforeClick() {
		setCheckedNodes();
		return isperp.submitForm({
			forceSync : true,
			success : function() {
				isperp.reloadParentControl();
			}
		});
	}
</script>